//
// CBezierPatch.java
// Copyright (C) 2010  "Naush" <naush _ hotmail _ fr>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>./* ----------------------------------------------------------------------------







package org.ryzom.nel.threed;

import org.ryzom.nel.misc.CVector;
import org.ryzom.nel.misc.CVectorD;

public class CBezierPatch {
  private long swigCPtr;
  protected boolean swigCMemOwn;

  public CBezierPatch(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  public static long getCPtr(CBezierPatch obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        nel3dJNI.delete_CBezierPatch(swigCPtr);
      }
      swigCPtr = 0;
    }
  }

  public void setVertices(CVector value) {
    nel3dJNI.CBezierPatch_Vertices_set(swigCPtr, this, CVector.getCPtr(value), value);
  }

  public CVector getVertices() {
    long cPtr = nel3dJNI.CBezierPatch_Vertices_get(swigCPtr, this);
    return (cPtr == 0) ? null : new CVector(cPtr, false);
  }

  public void setTangents(CVector value) {
    nel3dJNI.CBezierPatch_Tangents_set(swigCPtr, this, CVector.getCPtr(value), value);
  }

  public CVector getTangents() {
    long cPtr = nel3dJNI.CBezierPatch_Tangents_get(swigCPtr, this);
    return (cPtr == 0) ? null : new CVector(cPtr, false);
  }

  public void setInteriors(CVector value) {
    nel3dJNI.CBezierPatch_Interiors_set(swigCPtr, this, CVector.getCPtr(value), value);
  }

  public CVector getInteriors() {
    long cPtr = nel3dJNI.CBezierPatch_Interiors_get(swigCPtr, this);
    return (cPtr == 0) ? null : new CVector(cPtr, false);
  }

  public CBezierPatch() {
    this(nel3dJNI.new_CBezierPatch(), true);
  }

  public void make(CVector vertices, CVector normals) {
    nel3dJNI.CBezierPatch_make(swigCPtr, this, CVector.getCPtr(vertices), vertices, CVector.getCPtr(normals), normals);
  }

  public void makeInteriors() {
    nel3dJNI.CBezierPatch_makeInteriors(swigCPtr, this);
  }

  public void applyMatrix(SWIGTYPE_p_NLMISC__CMatrix m) {
    nel3dJNI.CBezierPatch_applyMatrix(swigCPtr, this, SWIGTYPE_p_NLMISC__CMatrix.getCPtr(m));
  }

  public CVector eval(float s, float t) {
    return new CVector(nel3dJNI.CBezierPatch_eval(swigCPtr, this, s, t), true);
  }

  public CVectorD evalDouble(double s, double t) {
    return new CVectorD(nel3dJNI.CBezierPatch_evalDouble(swigCPtr, this, s, t), true);
  }

  public CVector evalNormal(float s, float t) {
    return new CVector(nel3dJNI.CBezierPatch_evalNormal(swigCPtr, this, s, t), true);
  }

  public CVector evalTangentS(float s, float t) {
    return new CVector(nel3dJNI.CBezierPatch_evalTangentS(swigCPtr, this, s, t), true);
  }

  public CVector evalTangentT(float s, float t) {
    return new CVector(nel3dJNI.CBezierPatch_evalTangentT(swigCPtr, this, s, t), true);
  }

  public void subdivideS(CBezierPatch left, CBezierPatch right, float s) {
    nel3dJNI.CBezierPatch_subdivideS__SWIG_0(swigCPtr, this, CBezierPatch.getCPtr(left), left, CBezierPatch.getCPtr(right), right, s);
  }

  public void subdivideS(CBezierPatch left, CBezierPatch right) {
    nel3dJNI.CBezierPatch_subdivideS__SWIG_1(swigCPtr, this, CBezierPatch.getCPtr(left), left, CBezierPatch.getCPtr(right), right);
  }

  public void subdivideT(CBezierPatch top, CBezierPatch bottom, float t) {
    nel3dJNI.CBezierPatch_subdivideT__SWIG_0(swigCPtr, this, CBezierPatch.getCPtr(top), top, CBezierPatch.getCPtr(bottom), bottom, t);
  }

  public void subdivideT(CBezierPatch top, CBezierPatch bottom) {
    nel3dJNI.CBezierPatch_subdivideT__SWIG_1(swigCPtr, this, CBezierPatch.getCPtr(top), top, CBezierPatch.getCPtr(bottom), bottom);
  }

}
